package com.admin.education.models;

import com.admin.education.models.Enum.QuestionType;
import com.admin.education.repositories.Identifiable;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;

@Entity
@Table(name = "template_questions")
@EntityListeners(AuditingEntityListener.class)
@Data
public class TemplateQuestions implements Serializable,Identifiable{
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;
    @Column(name="examination_questions")
    @NotBlank
    @Length(max=1024)
    @NotNull
    private String examinationQuestions;
    @NotNull
    @Column(name = "question_type")
    private QuestionType questionType;;

    @OneToMany(mappedBy = "templateQuestions",cascade = CascadeType.REMOVE)
    @JSONField(serialize=false)
    private List<TemplateAnswers> templateAnswers;
    @OneToOne
    @NotNull
    @JSONField(serialize=false)
    private Templates templates;
    @Column(name="mark")
    @NotNull
    private BigDecimal mark;
    @OneToOne
    @NotNull
    private Subjects subjects;


}
